package com.haizhi.crm.sys.configure.model;

import com.haizhi.crm.common.constant.CrmConstant;
import com.haizhi.crm.common.model.BaseDo;
import com.haizhi.crm.common.util.CommonUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.Table;


/**
 * Created by caochao on 2018/05/31.
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@Entity
@Table(name = "ts_user_module" )
public class UserModuleDo extends BaseDo {

    private Long userId;
    private Long moduleId;

    public static UserModuleDo fromVo(ModuleVo moduleVo) {
        UserModuleDo userModuleDo = UserModuleDo.builder().moduleId(moduleVo.getModuleId()).userId(CommonUtils.getUserID()).build();
        userModuleDo.setCreatedById(CommonUtils.getUserID());
        userModuleDo.setUpdateById(CommonUtils.getUserID());
        userModuleDo.setEnabledFlag(CrmConstant.ENABLE_FLAG);
        return userModuleDo;
    }
}
